package com.abel.bigwater.dataserver.model.h86a

import io.netty.buffer.ByteBuf

class H86AAnalogChannel(count: Short) : H86AChannelBase<Int>(H86AChannelType.AnalogType, count) {
    /**
     * compute length of bytes.
     */
    override fun bufLength() = 1 + 2 * count

    override fun parseBuffer(buf: ByteBuf): Boolean {
        buf.readBytes(bufLength()).apply {
            super.parseBuffer(this)

            for (i in 1..count) {
                values.add(readUnsignedShort())
            }
        }

        return true
    }
}